<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ page language="java" contentType="text/html;charset=UTF-8"
	pageEncoding="UTF-8"%>


<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() 
	                   + ":" + request.getServerPort() + path + "/";
%>
<!DOCTYPE html>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<title>学生公寓管理系统</title>
	<!-- 引入css样式文件 -->
	<!-- Bootstrap Core CSS -->
	<link href="<%=basePath%>css/bootstrap.min.css" rel="stylesheet" />
	<!-- MetisMenu CSS -->
	<link href="<%=basePath%>css/metisMenu.min.css" rel="stylesheet" />
	<!-- DataTables CSS -->
	<link href="<%=basePath%>css/dataTables.bootstrap.css" rel="stylesheet" />
	<!-- Custom CSS -->
	<link href="<%=basePath%>css/sb-admin-2.css" rel="stylesheet" />
	<!-- Custom Fonts -->
	<link href="<%=basePath%>css/font-awesome.min.css" rel="stylesheet" type="text/css" />
	<link href="<%=basePath%>css/boot-crm.css" rel="stylesheet" type="text/css" />


</head>
<style>
	.form-horizontal .control-label{
		text-align:right;
		width:170px;
	}
	.form-control{
		width:80%;
	}
	.modal-footer{
		width:83%;
	}
</style>
<body>
<!-- 创建用户模态框 -->
<div id="form">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-label="Close">
					<span aria-hidden="true">&times;</span>
				</button>
				<h4 class="modal-title" id="myModalLabel">新建用户信息</h4>
			</div>
			<div class="modal-body">
				<form class="form-horizontal" id="new_user_form">
                   

					<div class="form-group">
						<label for="new_userName" class="col-sm-2 control-label">
						    用户名称
						</label>
						<div class="col-sm-10">
							<input type="text" class="form-control" id="new_userName" placeholder="用户名称" name="userName" />
						</div>
					</div>
					<div class="form-group">
						<label for="new_password" class="col-sm-2 control-label">密码</label>
						<div class="col-sm-10">
							<input type="text" class="form-control" id="new_password" placeholder="密码" name="password" />
						</div>
					</div>
					
					<div class="form-group">
						<label for="new_phone" class="col-sm-2 control-label">电话</label>
						<div class="col-sm-10">
							<input type="text" class="form-control" id="new_phone" placeholder="电话" name="phone" />
						</div>
					</div>
					<div class="form-group">
						<label for="new_identity" class="col-sm-2 control-label">身份</label>
						<div class="col-sm-10">
							<select	class="form-control" id="new_identity" name="identity">
								    <option value="">--请选择--</option>
									<option value="管理员">管理员</option>
									<option value="教师">教师</option>
									<option value="学生">学生</option>
							</select>
						</div>
					</div>
					

				</form>
			</div>
			<div class="modal-footer">
				<a href="${pageContext.request.contextPath }/login.action " class="btn btn-primary">返回</a>
				<button type="button" class="btn btn-primary" onclick="createUser()">创建用户</button>
			</div>
</div>


<script type="text/javascript">
//清空新建用户窗口中的数据
function clearUser() {
    $("#new_userName").val("");
    $("#new_password").val("");
    $("#new_phone").val("");
    $("#new_identity").val("");

}
   //创建用户
   function createUser() {

     $.post("${pageContext.request.contextPath}/user/createUser.action",
		
     $("#new_user_form").serialize(),function(data){
            if(data =="OK"){
               alert("用户创建成功！");
               window.location.reload();
            }else{
               alert("用户创建失败！");
               window.location.reload();
            }
        
           });

    }
</script>



<!-- 引入js文件 -->
<!-- jQuery -->
<script src="<%=basePath%>js/jquery-1.11.3.min.js"></script>
<!-- Bootstrap Core JavaScript -->
<script src="<%=basePath%>js/bootstrap.min.js"></script>
<!-- Metis Menu Plugin JavaScript -->
<script src="<%=basePath%>js/metisMenu.min.js"></script>
<!-- DataTables JavaScript -->
<script src="<%=basePath%>js/jquery.dataTables.min.js"></script>
<script src="<%=basePath%>js/dataTables.bootstrap.min.js"></script>
<!-- Custom Theme JavaScript -->
<script src="<%=basePath%>js/sb-admin-2.js"></script>
<!-- 编写js代码 -->
</body>
</html>